package dev.erge.net;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author erge
 */
public class UDPClientSample {

    public static void main(String[] args) {
        String sendMsg = "你好";
        InetAddress addr;
        try {
            addr = InetAddress.getByName("localhost");
            DatagramPacket packet = new DatagramPacket(sendMsg.getBytes(),
                    sendMsg.getBytes().length, addr, 8088);
            DatagramSocket socket = new DatagramSocket();
            socket.send(packet);
            socket.close();
        } catch (IOException ex) {
            Logger.getLogger(UDPClientSample.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
}
